new Vue({
    el:"#app",
    data: {
        user: {
            id: "",
            username: "",
            password: "",
            email: "",
            age: "",
            sex: ""
        },
        userList:[]
    },
    methods:{
       findAll:function () {
           var _this = this;
           axios.get('user/findAll.do')
               .then(function (response) {
                   _this.userList = response.data;
                   console.log(response);
               })
               .catch(function (error ) {
                   console.log(error);
               })
       },
        findById:function (userid) {
            var _this = this;
            axios.get('user/findById.do',{params:{id:userid}})
                .then(function (response) {
                    _this.user = response.data;
                  $("#myModal").modal("show");
                })
                .catch(function (error ) {
                    console.log(error);
                })
            
        },
        update:function (user) {
            var _this = this;
            axios.post('/user/updateUser.do',_this.user)
                .then(function () {
                    _this.findAll();
                })
                .catch(function (error) {
                    console.log(error);
                    _this.findAll();
                });
        },
    },
    created:function () {
        this.findAll();
    }
});